package com.bgy.common.exception;

import com.bgy.common.enums.CodeMsg;

/**
 * @description: 自定义通用异常
 * @author: yujie
 * @date 2019/4/24 10:01
 */
public class CommonException extends RuntimeException {

    // 错误码
    private String code;
    // 错误消息
    private String message;

    public CommonException(String code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public CommonException(CodeMsg codeMsg) {
        super(codeMsg.getMsg());
        this.code = codeMsg.getCode();
        this.message = codeMsg.getMsg();
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public static CommonException systemErrorException() {
        return new CommonException(CodeMsg.FAILED);
    }
}
